package com.util;

import java.io.Serializable;

public class ReturnResult implements Serializable {
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	private int code;
	private int status;
	private Object data;
	private String message = "";

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * 返回成功状态
	 * 
	 * @param obj
	 */
	public ReturnResult returnSuccess(Object obj,String msg) {
		this.code = 0;
		this.status = Constants.ReturnResult.SUCCESS;
		this.data = obj;
		this.message = msg;
		return this;
	}

	/**
	 * 返回默认成功状态
	 */
	public ReturnResult returnSuccess() {
		this.code = 0;
		this.status = Constants.ReturnResult.SUCCESS;
		return this;
	}

	/**
	 * 返回失败状态
	 * 
	 * @param message
	 */
	public ReturnResult returnFail(String message) {
		this.code = 1;
		this.status = Constants.ReturnResult.FAIL;
		this.message = message;
		return this;
	}

	public ReturnResult(String message, int status, Object data) {
		this.code = 1;
		this.message = message;
		this.status = status;
		this.data = data;
	}

	public ReturnResult(Object data) {
		this.code = 1;
		this.status = Constants.ReturnResult.SUCCESS;
		this.data = data;
	}

	public ReturnResult() {

	}
}
